package com.gxa.controller.parking;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.gxa.common.utils.Result;
import com.gxa.entity.parking.VehicleWSelect;
import com.gxa.entity.parking.VehicleWarn;
import com.gxa.service.parking.VehicleWarnService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author yjl
 * @since 2022-10-11 10:05:39
 */
@Api(tags = "车辆警告管理接口")
@RestController
@RequestMapping("/vehicle-warn")

public class VehicleWarnController {
    @Autowired
    private VehicleWarnService vehicleWarnService;

    @CrossOrigin(origins = "*", maxAge = 3600)//跨越请求配置
    @ApiOperation(value = "查询所有警告记录")
    @PostMapping("/vehicleWarnList")
    @ResponseBody
    public Result selectWarn(@RequestBody VehicleWSelect vehicleWSelect) {
        PageHelper.startPage(vehicleWSelect.getPageNum(),vehicleWSelect.getPageSize());
        List<VehicleWarn> vw= this.vehicleWarnService.selectAll();
        PageInfo<VehicleWarn> ve = new PageInfo<>(vw);
        return  Result.success(ve);
    }


    @CrossOrigin(origins = "*", maxAge = 3600)//跨越请求配置
    @ApiOperation("查询详情")
    @PostMapping("/warn/selectById/{id}")
    @ResponseBody
    public VehicleWarn selectById(@PathVariable("id") Integer id){

        VehicleWarn vehicleWarn = this.vehicleWarnService.selectById(id);
        return vehicleWarn;
    }


    @CrossOrigin(origins = "*", maxAge = 3600)//跨越请求配置
    @ApiOperation("多条件查询车辆告警记录")
    @PostMapping("/selectByCondition")
    @ResponseBody
    public Result selectByCondition(@RequestBody VehicleWSelect vehicleWSelect){
        PageHelper.startPage(vehicleWSelect.getPageNum(),vehicleWSelect.getPageSize());
        List<VehicleWarn> vs = this.vehicleWarnService.selectCondition(vehicleWSelect);
        PageInfo<VehicleWarn> ve = new PageInfo<>(vs);
        return Result.success(ve);
    }
}

